# coding = utf-8
from django.http import HttpResponse

# 进行标注操作
def label(request):
    # 加载自定义的标注方法库labelMethods
    import QipaoProject.methods.labelMethods as mds
    
    # 获取用户标记为“qipao”的图片的路径
    qipao_paths = request.POST.getlist('qipao')
    # 获取用户标记为“other”的图片的路径
    other_paths = request.POST.getlist('other')

    # 将标记为qipao的图片移动到qipao文件夹下
    for path in qipao_paths:
        mds.label_qipao(path)
    # 将标记为qipao的图片移动到qipao文件夹下
    for path in other_paths:
        mds.label_other(path)
        
    num = len(qipao_paths) + len(other_paths)
    # 接收ajax请求的话一定要返回一个HttpResponse对象
    return HttpResponse('已成功标注了' + str(num) + '张图片！')
